#include <iostream>

using namespace std;

void reshape_array(int* number_array, unsigned int m, unsigned int n);

int main() {
	unsigned int m, n;
	cin >> m >> n;
	int* number_array = new int[m * n];
	for (unsigned int i = 0; i < m * n; i++) {
		cin >> *(number_array + i);
	}
	reshape_array(number_array, m, n);
	delete[] number_array;
}

void reshape_array(int* number_array, unsigned int m, unsigned int n) {
	for (unsigned int i = 0; i < n; i++) {
		for (unsigned int j = 0; j < m; j++) {
			cout << *(number_array + j + m * i) << " ";
		}
		cout << endl;
	}
}